package com.example.database.db

import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RenameTable
import androidx.room.RoomDatabase
import androidx.room.migration.AutoMigrationSpec
import com.example.database.dao.VideoDao
import com.example.database.tables.VideoEntity

/**
 * 数据库
 * */
@Database(
    entities = [VideoEntity::class],//数据库中表格实体化对象数组 可以设置多个对象
    version = 1,//数据库版本号
    exportSchema = false,//导出路径
    autoMigrations = [
//        AutoMigration(
//            from = 1,
//            to = 2,
//            spec = AppDataBase.VideoAutoMigration::class
//        )
    ]//数据库自动升级
)
abstract class AppDataBase : RoomDatabase() {
    //获取数据表的操作对象
    abstract fun getVideoDao(): VideoDao

    @RenameTable(fromTableName = "video_table", toTableName = "video_table_new")
    class VideoAutoMigration : AutoMigrationSpec


}